using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using FrameWorkSystem.BusinessLayer.DataLayer;

namespace FrameWorkSystem.BusinessLayer
{
    public class Sys_UserPermissionFactory
    {

        #region data Members

        Sys_UserPermissionSql _dataObject = null;

        #endregion

        #region Constructor

        public Sys_UserPermissionFactory()
        {
            _dataObject = new Sys_UserPermissionSql();
        }

        #endregion


        #region Public Methods

        /// <summary>
        /// Insert new Sys_UserPermission
        /// </summary>
        /// <param name="businessObject">Sys_UserPermission object</param>
        /// <returns>true for successfully saved</returns>
        public bool Insert(Sys_UserPermission businessObject)
        {
            if (!businessObject.IsValid)
            {
                //Pthrow new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Insert(businessObject);

        }

        /// <summary>
        /// Update existing Sys_UserPermission
        /// </summary>
        /// <param name="businessObject">Sys_UserPermission object</param>
        /// <returns>true for successfully saved</returns>
        public bool Update(Sys_UserPermission businessObject)
        {
            if (!businessObject.IsValid)
            {
                //Pthrow new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Update(businessObject);
        }

        /// <summary>
        /// get Sys_UserPermission by primary key.
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>Student</returns>
        public Sys_UserPermission GetByPrimaryKey(Sys_UserPermissionKeys keys)
        {
            return _dataObject.SelectByPrimaryKey(keys); 
        }

        /// <summary>
        /// get list of all Sys_UserPermissions
        /// </summary>
        /// <returns>list</returns>
        public List<Sys_UserPermission> GetAll()
        {
            return _dataObject.SelectAll(); 
        }
        public List<Sys_UserPermission> GetNoPermission(string uName, FrameWorkSystem.PhanQuyen.TypeOfFunc _type)
        {
            return _dataObject.GetNoPermission(uName,false, _type);
        }
        /// <summary>
        /// get list of Sys_UserPermission by field
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public List<Sys_UserPermission> GetAllBy(Sys_UserPermission.Sys_UserPermissionFields fieldName, object value)
        {
            return _dataObject.SelectByField(fieldName.ToString(), value);  
        }
        public List<Sys_UserPermission> GetAllByType(PhanQuyen.TypeOfFunc type, string Uname)
        {
            return _dataObject.GetAllByType(type, Uname);
        }
        /// <summary>
        /// delete by primary key
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>true for succesfully deleted</returns>
        public bool Delete(Sys_UserPermissionKeys keys)
        {
            return _dataObject.Delete(keys); 
        }

        /// <summary>
        /// delete Sys_UserPermission by field.
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>true for successfully deleted</returns>
        public bool Delete(Sys_UserPermission.Sys_UserPermissionFields fieldName, object value)
        {
            return _dataObject.DeleteByField(fieldName.ToString(), value); 
        }

        #endregion

    }
}
